package com.example.scala.source

import com.example.java.source.MyParallelSource
import org.apache.flink.streaming.api.functions.source.SourceFunction.SourceContext
import org.apache.flink.streaming.api.scala._
object MySelfSourceMain {
  var tmp:Long = 0

  def main(args: Array[String]): Unit = {
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

//    val data: DataStream[String] = env.addSource((ctx: SourceContext[String]) => {
//      while (true) {
//        ctx.collect(tmp.toString)
//        Thread.sleep(1000)
//        tmp += 1
//      }
//    })

    // 可以复用java的类
    val data: DataStream[String] = env.addSource(new MyParallelSource)

    data.print
    env.execute()
  }

}
